home *** CD-ROM | disk | FTP | other *** search
- Attribute VB_Name = "MainModule"
- ' Written for West End Software, Inc.
- ' Copyright ⌐ 1997 Michael L. Jones
- ' All Rights Reserved.
-
- ' Warning: This computer program is protected by
- ' copyright law and international treaties.
- ' Unauthorized reproduction or distribution of this
- ' program, or any portion of it, may result in
- ' severe civil and criminal penalties, and will be
- ' prosecuted to the maximum extent possible under
- ' the law.
-
- Option Explicit
-
- ' wesCommonLibrary sample project
-
- ' public constants
- Public Const csProjName = "Sample"
-
- ' private constants
- Private Const csModName = "MainModule"
-
- ' replace with valid values to prevent
- ' "unregistered" message box from appearing
- ' when initializing Library object
- Private Const csUserName = "My UserName"
- Private Const csLicenseNumber = 1234567890
-
- ' replace with resource file string if you end up
- ' using something like this
- Private Const csFatalError = _
- "An unrecoverable error has occurred:"
-
- ' public properties
- Public Library As Library
-
- ' public procedures
- Public Sub Main()
-
- On Error GoTo CatchError
- Const csProcName = csProjName & "." & _
- csModName & ".Main"
-
- ' initialize a wesCommonLibrary Application
- ' object
- Dim oLibraryApp As _
- wesCommonLibraryVB4.Application
- Set oLibraryApp = _
- New wesCommonLibraryVB4.Application
-
- ' set the UserName and LicenseNumber
- ' properties
- oLibraryApp.UserName = csUserName
- oLibraryApp.LicenseNumber = csLicenseNumber
-
- ' initialize the library object; (the sample
- ' values used for the UserName and
- ' LicenseNumber properties will cause the
- ' "unregistered" message box to appear;
- ' using valid values will prevent this)
- Set Library = oLibraryApp.Library
-
- ' release the Application object
- Set oLibraryApp = Nothing
-
- ' load and show the main form
- Load frmMain
- frmMain.Show
-
- Exit Sub
-
- CatchError:
-
- ' replace with you choice of error handling
-
- ' no recovery possible; display error
- DisplayError csFatalError, Err.Number, _
- Err.Description, csProcName
-
- ' make sure that the main form is gone
- Unload frmMain
-
- Exit Sub
-
- End Sub
-
- Public Sub DisplayError(ByRef Message As String, _
- ByRef Number As Long, ByRef Description _
- As String, ByRef Source As String)
-
- On Error Resume Next
-
- ' display error message
- Dim sMsg As String
- sMsg = Message & vbCrLf & vbCrLf & Source & _
- vbCrLf & CStr(Number) & "-" & Description
- MsgBox sMsg, vbInformation, App.Title
-
- End Sub
-
- Public Sub Terminate()
-
- On Error Resume Next
-
- ' release all object references,
- ' allowing application to terminate
- Set Library = Nothing
-
- End Sub
-